<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>登陆页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- CSS -->
    <link rel="stylesheet" th:href="@{/css/reset.css}">
    <link rel="stylesheet" th:href="@{/css/supersized.css}">
    <link rel="stylesheet" th:href="@{/css/style.css}">
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
</head>
<body>
<div class="page-container">
    <h1>登陆</h1>
       <div>
        <input  id="username" type="text" name="username" class="username" placeholder="输入用户名/邮箱/手机号">
        <input  id="pass" type="password" name="pass" class="pass" placeholder="输入登录密码">
        <button  id="btn_login" type="submit">登陆</button>
       <div>

</div>
<!-- Javascript -->
<script th:src="@{/js/jquery-1.8.2.min.js}"></script>
<script th:src="@{/js/supersized.3.2.7.min.js}"></script>
<script th:src="@{/js/supersized-init.js}"></script>
<script th:src="@{/js/toast_367A9.js}"></script>
<script th:src="@{/js/scripts.js}"></script>
<script type="text/javascript" >
    $(function(){

        $("#btn_login").click(function(){ //登录

            var username = $("#username").val();
            var pass = $("#pass").val();
            if (username == '') {
                ToastShow("登录帐号不能为空");
                return false;
            }
            if (pass == '') {
                ToastShow("登录密码不为空");
                return false;
            }
            var json={username:username,pass:pass};
            $.ajax({
                url : "/user/dologin",
                type: 'POST',
                dataType:'json',
                contentType:"application/json",
                data: JSON.stringify(json),
                dataType:"text",

                success : function(data) {

                    var dats=JSON.parse(data);

                 if (dats.status==200){

                        ToastShow("登陆成功");
                        var loginuser=dats.data;
                        localStorage.setItem("loginuser",JSON.stringify(loginuser));
                        window.location.href="/user/index";
                    } else{

                        ToastShow(dats.msg);
                  }
                },
                error : function(req, err, ex) {
                    $("#txtRep").val(req.responseText + "\r\n" + err + "\r\n" + ex);
                }
            });




        });

    });

</script>
</body>
</html>



